<!-- 后台登录注册控制器 -->
<?php
namespace admin\Controller;
	use Think\Controller;
	class PublicController extends Controller{
		public function _initialize(){
			if(empty($_SESSION['admin_member'])){
			$this->redirect('Public/login');
		}
		//执行登陆
	public function dologin()
	{
		//接收用户名和密码
		$username = I('post.uname');
		// var_dump($username);die;
		$password = I('post.password');
		$code=I('post.verify');
		//验证
		$user = M('users');
		$data = $user->where(array('uname'=>$uname))->find();
		if (!$data) {
			$this->error('用户名不存在！');
			exit;
		}
		//验证密码
		if ($data['password'] !=$password) {
			$this->error('密码不正确');
			exit;
		}
		$verify = new \Think\Verify();   
		$result = $verify->check($code);
		if($result){
		//把用户信息添加到session
		$_SESSION['users'] = $data;
		// var_dump($_SESSION['admin_user']);die;
		//跳转到后台首页
		$this->redirect('Index/index');			
		}else{
			$this->error('验证码不正确');
		}
	}
	  
	}
}
